package com.example.demo.services;

import com.example.demo.dao.ArticleDao;
import com.example.demo.dao.ArticleLabelDao;
import com.example.demo.model.ArticleLabelModel;
import com.example.demo.model.ArticleModel;
import com.example.demo.model.LabelModel;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ArticleLabelService {
    @Resource
    ArticleLabelDao articleLabelDao;


    public PageInfo getArticleLabelListFromDb(
            int pageNum,
            int pageSize
    ) {
        PageHelper.startPage(pageNum, pageSize);
        return new PageInfo(getArticleLabelListFromDb());
    }

    /**
     * 获取标签所有列表
     * @return
     */
    public List<ArticleLabelModel> getArticleLabelListFromDb(){
        return articleLabelDao.getArticleLabelList();
    }

    public ArticleLabelModel getArticleLabelInfo(Long id) {
        return articleLabelDao.getArticleLabelInfoById(id);
    }

    public int add(ArticleLabelModel articleLabelModel) {
        return articleLabelDao.addArticleLabel(articleLabelModel);
    }

    public boolean batchInsert(List<ArticleLabelModel> labelModelList) { return articleLabelDao.insertListBatch(labelModelList); }

    public boolean edit(ArticleLabelModel articleLabelModel) {
        return articleLabelDao.updateArticleLabelById(articleLabelModel);
    }

    public boolean del(Long id) {
        return articleLabelDao.del(id);
    }

}
